<?php
namespace app\api\controller\pgb;
use x\Xbase;
use x\G;
class Base extends Xbase
{
    public $sys = [];
    public $userinfo = [];
    public function __construct()
    {
        parent::__construct();
        $this->_sys();
        $this->_user();
    }
    //通用
    public function _sys(){
        $this->sys = m('Deploy','xcom')->lists();
        G::$exts['api_version'] = $this->sys['api_version'];
        $this->assign('sys',$this->sys);
    }

    //用户信息
    public function _user(){
        $token = $this->post('token');
        $partner = $this->post('partner');
        G::$exts['partner'] = $partner;
        if($token){
            if (in_array($partner, [5100,5200])) {
                $rs = $this->db->query("select * from user where app_token=?",[$token],1);
            }else{
                $rs = $this->db->query("select * from user where wap_token=?",[$token],1);
            }
            $this->userinfo = $rs ? $rs : [];
        }
    }
    //验证登录
    public function checkLogin(){
        if(!$this->userinfo){
            if(is_post()){
                err('请先登录!',200);
            }
        }
    }
}
